package luccy.registry;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import luccy.util.AssertionUtil;

public class SingletonCache {

	private static final Map<Class, Object> cache = new ConcurrentHashMap<Class, Object>();

	@SuppressWarnings("unchecked")
	public static <T> T get(Class<? extends T> clazz) {
		return (T) cache.get(clazz);
	}

	public static <T> void save(Class<? extends T> clazz, T t) {
		AssertionUtil.assertNotNull(clazz);
		AssertionUtil.assertNotNull(t);
		cache.put(clazz, t);
	}

}
